package com.imooc.lib_base.base

import android.os.Build
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity


abstract class BaseActivity : AppCompatActivity() {

    //获取布局ID
    abstract fun getLayoutId():Int
    //获取标题
    abstract fun getTitleText():String

    //初始化操作
    abstract  fun initView()


    //是否显示返回按键
   abstract  fun isShowBack():Boolean

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())

     /*   if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
            supportActionBar?.let {
                it.title=getTitleText()
                it.setDisplayHomeAsUpEnabled(isShowBack())
                it.elevation=0f
            }
        }*/
        initView()
    }


    //响应ActionBar 上面的点击事件
    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        if(item.itemId==android.R.id.home){
            finish()
        }
        return true;
    }

}